<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态绑定 class 属性——对象语法</title>
    <script src="../../../../../js/vue.global.js"></script>
    <style>
        .colordecorate {
            color: red;
        }

        .textdecorate {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div id="app">
    <h1 class="colordecorate">Hello, World!</h1>
    <!--   对象语法格式：{类名1:true/false, 类名2:true/false,...} -->
    <h1 v-bind:class="{textdecorate: true, colordecorate: true}">Hello, World!</h1>
    <h1 v-bind:class="{textdecorate: isTextDecorated, colordecorate: isColorDecorated}">Hello, World!</h1>

    <h1 v-bind:class="getClass()">Hello, World!</h1>
</div>

<script>
    const app = Vue.createApp({
        data() {
            return {
                isTextDecorated: true,
                isColorDecorated: true,
            }
        },

        methods:{
            getClass(){
                return {textdecorate: this.isTextDecorated, colordecorate: this.isColorDecorated}
            }
        }
    })
    app.mount("#app")
</script>
</body>
</html>